home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.09 Sep 90 / Object1 Folder / CShape.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-11  |  1.5 KB  |  89 lines  |  [TEXT/KAHL]

  1. /*
  2.  *     Source    - CShape.c
  3.  *    Author    - Mark Bykerk Kauffman
  4.  *  Purpose    - This file contains the implementaion of the methods
  5.  *            defined the by shape classes in CShape.h
  6.  */                                                                
  7.         
  8. #include "CShape.h"             
  9. #include "Quickdraw.h"
  10.  
  11. void CShape :: Draw(void)
  12. {
  13. }
  14.  
  15. void CShape :: Erase(void)
  16. {
  17. }
  18.  
  19. void CShape :: SetShapeLoc(Left,Top,Right,Bottom)
  20. int Left;
  21. int Top;
  22. int Right;
  23. int    Bottom;
  24. {
  25.     Rect    Location;                
  26.     /* LOCAL location variable */
  27.     
  28.     SetRect(&Location,Left,Top,Right,Bottom);
  29.     this->Location = Location;
  30.     /*        
  31.      *    Set the instance variable Location to 
  32.      *    the local Location value.  The 
  33.      *    reason for doing this is that Semantec
  34.      *    states in the TNINK C manual
  35.      *    "Your program should not rely on the
  36.      *    addresses of instance variables...".
  37.      *    Semantec describes the above technique as
  38.      *    "shadowing".
  39.      */
  40. }
  41.  
  42. void COval :: Draw(void)
  43. {
  44.     Rect    Location;
  45.     
  46.     Location = this->Location;    
  47.     FrameOval(&Location);        
  48. }
  49.  
  50. void COval :: Erase(void)
  51. {
  52.     Rect    Location;
  53.     
  54.     Location = this->Location;
  55.     EraseOval(&Location);    
  56. }
  57.  
  58. void CRectangle :: Draw(void)
  59. {    
  60.     Rect    Location;
  61.     
  62.     Location = this->Location;
  63.     FrameRect(&Location);    
  64. }
  65.  
  66. void CRectangle :: Erase(void)
  67. {    
  68.     Rect    Location;
  69.     
  70.     Location = this->Location;
  71.     EraseRect(&Location);    
  72. }
  73.  
  74. void CLine :: Draw(void)
  75. {
  76.     MoveTo(Location.left,Location.top);
  77.     LineTo(Location.right,Location.bottom);        
  78. }
  79.  
  80. void CLine :: Erase(void)
  81. {
  82.     int                oldPenMode;
  83.  
  84.     oldPenMode = thePort->pnMode;
  85.     PenMode(notPatCopy);
  86.     MoveTo(Location.left,Location.top);
  87.     LineTo(Location.right,Location.bottom);
  88.     PenMode(oldPenMode);            
  89. }